﻿<Window x:Class="SqlAServer.MainWindow"
        xmlns:core="clr-namespace:sqCore;assembly=sqCore"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="SqlAServer" Height="634.987" Width="874.5" Icon="util\ico.ico">
    <Window.Resources>
        <core:TimeToLocalTimeCoverter x:Key="TimeToLocalTimeCoverter"/>
    </Window.Resources>        

    <Grid Margin="0,0,0,-3" RenderTransformOrigin="0.5,0.5" Background="#FF323232">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0*"/>
            <ColumnDefinition Width="827*"/>
            <ColumnDefinition Width="16*"/>
            <ColumnDefinition Width="15"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="117"/>
            <RowDefinition Height="153.5"/>
            <RowDefinition Height="66"/>
            <RowDefinition/>
            <RowDefinition Height="29"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Border BorderBrush="#FF878787" BorderThickness="1,0.6,0.5,0.6" Margin="-7,51,-14,30" Grid.ColumnSpan="4" Grid.RowSpan="3"/>
        <Slider x:Name="State" HorizontalAlignment="Left" Margin="100,18,0,0" VerticalAlignment="Top" Width="35" ValueChanged="Slider_ValueChanged" RenderTransformOrigin="1,2" Maximum="1" SmallChange="10" LargeChange="0.1" AutoToolTipPlacement="TopLeft" IsSnapToTickEnabled="True" Height="22" Foreground="#FFFF1414" Grid.Column="1">
            <Slider.Background>
                <RadialGradientBrush>
                    <GradientStop Color="#FF323232" Offset="1"/>
                    <GradientStop Color="#FFF0E46B"/>
                </RadialGradientBrush>
            </Slider.Background>
        </Slider>
        <Label Content="OFF" HorizontalAlignment="Left" Margin="68,16,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.609,3.059" Height="24" Width="31" Foreground="#FFECCB37" Grid.Column="1"/>
        <Label Content="ON" HorizontalAlignment="Left" Margin="134,16,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.609,3.059" Height="24" Width="26" Foreground="#FFECCB37" Grid.Column="1"/>
        <Label x:Name="StateLable" Content="STATE:" HorizontalAlignment="Left" Margin="13,16,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.609,3.059" Height="24" Width="53" FontWeight="Bold" Foreground="Red" Grid.ColumnSpan="2"/>
        <ProgressBar x:Name="WorkingBar" Height="16" Margin="0,19,0,0" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Width="54" Grid.ColumnSpan="2"/>

        <Label Content="Name" HorizontalAlignment="Left" Margin="15,69,0,0" VerticalAlignment="Top" Width="43" Foreground="#FFECCB37" Height="24" Grid.Column="1"/>
        <TextBox x:Name="NameBox" HorizontalAlignment="Left" Height="23" Margin="16,88,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="106" Background="#FF6A6A6A" BorderBrush="White" Foreground="White" Grid.Column="1"/>
        <Label Content="Type" HorizontalAlignment="Left" Margin="129,69,0,0" VerticalAlignment="Top" Width="38" Foreground="#FFECCB37" Grid.Column="1" Height="24"/>
        <ComboBox x:Name="TypeCBox" HorizontalAlignment="Left" Margin="131,88,0,0" VerticalAlignment="Top" Width="106" Background="#FF6A6A6A" Height="23" Foreground="Black" FontWeight="Bold" IsReadOnly="True" Grid.Column="1">
            <ComboBox.BorderBrush>
                <RadialGradientBrush>
                    <GradientStop Color="Black" Offset="0.09"/>
                    <GradientStop Color="White" Offset="0.445"/>
                    <GradientStop Color="Black" Offset="1"/>
                </RadialGradientBrush>
            </ComboBox.BorderBrush>
            <ComboBoxItem Content="Oracle" HorizontalAlignment="Left" Width="104"/>
            <ComboBoxItem Content="MSSQL" HorizontalAlignment="Left" Width="104"/>
            <ComboBoxItem Content="Mongo" HorizontalAlignment="Left" Width="104"/>
        </ComboBox>
        <Label Content="Host" HorizontalAlignment="Left" Margin="245,69,0,0" VerticalAlignment="Top" Width="36" Foreground="#FFECCB37" Grid.Column="1" Height="24"/>
        <TextBox x:Name="HostBox" HorizontalAlignment="Left" Height="23" Margin="248,88,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="106" Background="#FF6A6A6A" BorderBrush="White" Foreground="White" Grid.Column="1"/>
        <Label Content="Service Name" HorizontalAlignment="Left" Margin="362,69,0,0" VerticalAlignment="Top" Width="87" Foreground="#FFECCB37" Grid.Column="1" Height="24"/>
        <TextBox x:Name="ServiceNameBox" HorizontalAlignment="Left" Height="23" Margin="364,88,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="106" Background="#FF6A6A6A" BorderBrush="White" Foreground="White" Grid.Column="1"/>
        <Label Content="User Name" HorizontalAlignment="Left" Margin="480,69,0,0" VerticalAlignment="Top" Width="72" Foreground="#FFECCB37" Height="24" Grid.Column="1"/>
        <TextBox x:Name="UserNameBox" HorizontalAlignment="Left" Height="23" Margin="481,88,0,0" TextWrapping="Wrap" VerticalAlignment="Top"  Width="106" Background="#FF6A6A6A" BorderBrush="White" Foreground="White" Grid.Column="1"/>
        <Label Content="Password" HorizontalAlignment="Left" Margin="595,69,0,0" VerticalAlignment="Top" Width="64" Foreground="#FFECCB37" Grid.Column="1" Height="24"/>
        <TextBox x:Name="PassBox" HorizontalAlignment="Left" Height="23" Margin="597,88,0,0" TextWrapping="Wrap" VerticalAlignment="Top"  Width="106" Background="#FF6A6A6A" BorderBrush="White" Foreground="White" Grid.Column="1"/>
        <Label Content="Port" HorizontalAlignment="Left" Margin="711,69,0,0" VerticalAlignment="Top" Width="64" Foreground="#FFECCB37" Grid.Column="1" Height="24"/>
        <TextBox x:Name="PortBox" Height="23" Margin="714,88,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Background="#FF6A6A6A" BorderBrush="White" Foreground="White" Grid.Column="1" HorizontalAlignment="Left" Width="104"/>
        <Button x:Name="AddNewDBClickedPB" Content="Add New DB" Margin="27,0,0,43" Click="AddNewDBClicked" Foreground="#FFECCB37" Grid.Column="1" Grid.Row="2" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="100">
            <Button.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF938989" Offset="0"/>
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF807979" Offset="0.3"/>
                </LinearGradientBrush>
            </Button.Background>
        </Button>
        <Button x:Name="ChangeDBPB" Content="Change DB " Margin="147,0,0,43" VerticalAlignment="Bottom" Click="ChangeDBClicked" Foreground="#FFECCB37" Grid.Column="1" Grid.Row="2" Height="20" HorizontalAlignment="Left" Width="100">
            <Button.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF938989" Offset="0"/>
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF807979" Offset="0.3"/>
                </LinearGradientBrush>
            </Button.Background>
        </Button>
        <Button x:Name="RemoveBPB" Content="Remove DB" HorizontalAlignment="Left" Margin="267,0,0,43" VerticalAlignment="Bottom" Width="100" Click="RemoveDBClicked" Foreground="#FFECCB37" Grid.Column="1" Grid.Row="2" Height="20">
            <Button.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF938989" Offset="0"/>
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF807979" Offset="0.3"/>
                </LinearGradientBrush>
            </Button.Background>
        </Button>



        <DataGrid x:Name="DBTable" ItemsSource="{Binding DBList}" AutoGenerateColumns="False"  Margin="15,5,8,6" IsTextSearchEnabled="True" SelectionUnit="Cell" Background="#FF6A6A6A" BorderBrush="White" Foreground="Black" RowBackground="#FFAAA6A6" HorizontalGridLinesBrush="#FFE8E8E8" VerticalGridLinesBrush="#FFE8E8E8" IsReadOnly="True" FontWeight="Bold" Grid.ColumnSpan="3" MouseDoubleClick="DBTable_MouseDoubleClick" Grid.Row="1" LoadingRow="DBTable_LoadingRow">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*" />
                <DataGridTextColumn Header="Type" Binding="{Binding DBType}" Width="*" />
                <DataGridTextColumn Header="Host" Binding="{Binding Host}" Width="*" />
                <DataGridTextColumn Header="Service Name" Binding="{Binding ServiceName}" Width="*" />
                <DataGridTextColumn Header="User" Binding="{Binding UserName}" Width="*" />
                <DataGridTextColumn Header="Password" Binding="{Binding Password}" Width="*" />
                <DataGridTextColumn Header="Port" Binding="{Binding Port}" Width="*" />
            </DataGrid.Columns>
        </DataGrid>
        <Label x:Name="DBListLable" Content="DB List:" HorizontalAlignment="Left" Margin="13,51,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.609,3.059" Height="24" Width="53" FontWeight="Bold" Foreground="#FFECCB37" Grid.ColumnSpan="2"/>


        <Label x:Name="TaskListLable" Content="Task List" HorizontalAlignment="Left" Margin="13,0,0,7" VerticalAlignment="Bottom" RenderTransformOrigin="0.609,3.059" Height="24" Width="67" FontWeight="Bold" Foreground="#FFECCB37" Grid.ColumnSpan="2" Grid.Row="2" />
        <DataGrid x:Name="TaskListTable" ItemsSource="{Binding TaskList}" AutoGenerateColumns="False" Margin="15,62,8,12" IsTextSearchEnabled="True" SelectionUnit="Cell" AreRowDetailsFrozen="True"  Background="#FF6A6A6A" BorderBrush="White" Foreground="Black" RowBackground="#FFAAA6A6" HorizontalGridLinesBrush="#FFE8E8E8" VerticalGridLinesBrush="#FFE8E8E8" IsReadOnly="True" FontWeight="Bold" Grid.ColumnSpan="3" MouseDoubleClick="TaskListTable_MouseDoubleClick"  SelectedIndex="{Binding SelectedIndex}" Grid.Row="2" Grid.RowSpan="2" LoadingRow="TaskListTable_LoadingRow" >
            <DataGrid.Columns>
                <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*" />
                <DataGridTextColumn Header="Creator" Binding="{Binding Creator}" Width="*" />
                <DataGridTextColumn Header="Last run time" Binding="{Binding LastRunTime, Converter={StaticResource TimeToLocalTimeCoverter}}" Width="*" />
                <DataGridTextColumn Header="Next run time" Binding="{Binding NextRunTime, Converter={StaticResource TimeToLocalTimeCoverter}}" Width="*" />
                <DataGridCheckBoxColumn Header="Is active?" Binding="{Binding IsActive}" />
                <DataGridCheckBoxColumn Header="Status" Binding="{Binding IsOk}"/>                                                
            </DataGrid.Columns>
            
        </DataGrid>
        <Button x:Name="TaskStatePB" Content="Stop \ Renew" Margin="27,0,0,11" Click="TaskActiveChangeClicked" Foreground="#FFECCB37" Grid.Column="1" Grid.Row="3" Height="20" VerticalAlignment="Bottom" Grid.RowSpan="2" HorizontalAlignment="Left" Width="100">
            <Button.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF938989" Offset="0"/>
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF807979" Offset="0.3"/>
                </LinearGradientBrush>
            </Button.Background>
        </Button>
        <Button x:Name="RunTaskNowPB" Content="Run Now" Margin="147,0,0,11" VerticalAlignment="Bottom" Click="RunNowClicked" Foreground="#FFECCB37" Grid.Column="1" Grid.Row="3" Height="20" Grid.RowSpan="2" HorizontalAlignment="Left" Width="100">
            <Button.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF938989" Offset="0"/>
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF807979" Offset="0.3"/>
                </LinearGradientBrush>
            </Button.Background>
        </Button>
        <Button x:Name="TaskNextPB" Content="Next" HorizontalAlignment="Left" Margin="267,0,0,11" VerticalAlignment="Bottom" Width="100" Click="NextClicked" Foreground="#FFECCB37" Grid.Column="1" Grid.Row="3" Height="20" Grid.RowSpan="2">
            <Button.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF938989" Offset="0"/>
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF807979" Offset="0.3"/>
                </LinearGradientBrush>
            </Button.Background>
        </Button>
        <Button x:Name="TaskNextToNowPB" Content="Next To Now" HorizontalAlignment="Left" Margin="387,0,0,11" VerticalAlignment="Bottom" Width="100" Click="NextToNowClicked" Foreground="#FFECCB37" Grid.Column="1" Grid.Row="3" Height="20" Grid.RowSpan="2">
            <Button.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF938989" Offset="0"/>
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF807979" Offset="0.3"/>
                </LinearGradientBrush>
            </Button.Background>
        </Button>
        <Button x:Name="EditTaskJsonPB" Content="Edit Json" HorizontalAlignment="Left" Margin="507,0,0,11" VerticalAlignment="Bottom" Width="100" Click="TaskEditJsonClicked" Foreground="#FFECCB37" Grid.Column="1" Grid.Row="3" Height="20" Grid.RowSpan="2">
            <Button.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF938989" Offset="0"/>
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF807979" Offset="0.3"/>
                </LinearGradientBrush>
            </Button.Background>
        </Button>
        <Button x:Name="TaskGetLogsPB" Content="Get Logs" HorizontalAlignment="Left" Margin="627,0,0,11" VerticalAlignment="Bottom" Width="100" Click="TaskGetLogsClicked" Foreground="#FFECCB37" Grid.Column="1" Grid.Row="3" Height="20" Grid.RowSpan="2">
            <Button.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FF938989" Offset="0"/>
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF807979" Offset="0.3"/>
                </LinearGradientBrush>
            </Button.Background>
        </Button>

    </Grid>
</Window>